﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aier.dataaccess.model
{
	public class LeadDto
	{
		/// <summary>
		/// 建档时间
		/// </summary>
		public DateTime? new_inputingtime { get; set; }

		/// <summary>
		/// 手机
		/// </summary>
		public string address1_telephone1 { get; set; }

		/// <summary>
		/// 说明
		/// </summary>
		public string description { get; set; }

		/// <summary>
		/// 姓名
		/// </summary>
		public string lastname { get; set; }

		/// <summary>
		/// 年龄
		/// </summary>
		public int? new_age { get; set; }

		/// <summary>
		/// 出生日期
		/// </summary>
		[DateTimeMin(ErrorMessage = "出生日期不能小于1900/01/01")]
		public DateTime? new_birthdate { get; set; }

		/// <summary>
		/// 身份证号
		/// </summary>
		public string new_citizenid { get; set; }

		/// <summary>
		/// 数据来源 6-商务通
		/// </summary>
		public int? new_datasource { get; set; }

		/// <summary>
		/// 病种
		/// </summary>
		public int? new_disease { get; set; }

		/// <summary>
		/// 性别
		/// </summary>
		public int? new_gender { get; set; }

		/// <summary>
		/// 推广来源
		/// </summary>
		public int? new_mxqd { get; set; }

		/// <summary>
		/// 建档场景 1: 互动咨询（在线）
		/// </summary>
		public int? new_patientsource { get; set; }

		/// <summary>
		/// 预约时间 赋值到 new_sourceremark(建档场景说明)
		/// </summary>
		public string new_reservationdate { get; set; }

		/// <summary>
		/// CRM账号
		/// </summary>
		[Required]
		public string ownerid { get; set; }
	}


	public class DateTimeMinAttribute : ValidationAttribute
	{ 
	
		protected override ValidationResult IsValid(object value, ValidationContext validationContext)
		{
			var result = ValidationResult.Success;
			var dateValue = (DateTime?)value;
			var minDateValue = DateTime.Parse("01/01/1900 00:00:00");
			
			if (dateValue.HasValue)
			{
				if (dateValue.Value <= minDateValue)
				{
					result = new ValidationResult(ErrorMessage);
				}
			}
			return result;
		}
	}
}
